﻿using System;
//using msBsc.AppLogic.Hrp;
//using Ghw;

namespace msBsc.WebUi.CustomerSys
{
    public partial class wfTHome : msBsc.Cls.BPProxy
    {
        //protected override void OnInit(EventArgs e)
        //{
        //    base.OnInit(e);

        //    Literal litUrl = new Literal();
        //    litUrl.Text = string.Format(@"<script src='{0}' type='text/javascript'></script>", msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "jqPlugin/js/Loginox.js");
        //    this.Header.Controls.AddAt(1, litUrl);
        //}
        //UserInfo userinfo = new UserInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(gettable());
            //return;
            Response.Clear();
            //Response.AddHeader("Content-Type", "application/json; charset=GB2312");


            //Response.CacheControl = "no-cache";             //设置页面无缓存
            Response.Expires = -1;
            Response.CacheControl = "no-cache";

            //if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), "includeScript"))
            //{
            //    Page.ClientScript.RegisterClientScriptInclude(GetType(), "includeScript", "~/SCript/JScript.js");
            //}
            if (!IsPostBack && !IsCallback)
            {
                //userinfo.GetUserInfo();
                //if (!userinfo.IsAdmin)
                //{
                //    Response.Redirect(msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "pages/admin/wfLogin.aspx");
                //}
                //fForumPage.User.Name
                //if (!string.IsNullOrEmpty(this.Request.Params["LOGING"]) && this.Request.Params["LOGING"] == "OUT")
                //{
                //    userinfo.ExitSys();
                //}
                //if (userinfo.UserId == null || userinfo.UserId == string.Empty)
                //{
                //    //FormsAuthentication.RedirectToLoginPage();
                //}&& Request.Path.ToUpper().IndexOf("WFLOGIN.ASPX") != -1

                //if (this.operRole != "IS_PARTNER" )
                //{
                //    HttpContext.Current.Response.Redirect("~/wfHome.aspx");
                //    return;
                //}


                //CBizBsePartner op = new CBizBsePartner();
                //DataSet ds = op.SelectByPartnerCde(this.OperatorOffice);
                //string showUser = string.Empty;

                //using (msBsc.AppLogic.DataAlc.CBizCustomerRegister objCBizCustomerRegister = new AppLogic.DataAlc.CBizCustomerRegister())
                //{
                //    System.Data.DataSet ds = objCBizCustomerRegister.SelectById(msBsc.SvRef.UserInfo.Operator);

                //    if (ds != null && ds.Tables[0].Rows.Count > 0)
                //    {
                //        SetContrlValue("txtUserShow", ds.Tables[0].Rows[0]["CUSTOMER_NICK"].ToString());
                //    }
                //    else
                //    {
                //        SetContrlValue("txtUserShow", "");
                //    }
                //}
                SetContrlValue("txtUserShow", msBsc.SvRef.UserInfo.OperatorName);

                //if (ds.Tables[0].Rows.Count > 0)
                //{
                //    CBizBseConstantDict oconst = new CBizBseConstantDict();
                //    txtUserShow.Text += oconst.GetContantDispText("BSE_RP_COLL_POLICY_CID", ds.Tables[0].Rows[0]["RP_COLL_POLICY_CID"].ToString());
                //}
                //doShowMsg();
                DoDateTimeShow();
                GetBusineFlowHtml();
                GetSysNoHtml();
                //this.SetContrlValue("divmenushow", GetBusineFlowHtml());
                //AddPageLoadData("SHIPMENT_LIST_LINK", GetBusineFlowHtml());


                //ShowLogo();
                //UpText();
                //DisplayMenu();
                //clientTabStrip.ClientEvents.TabSelect = new ClientEvent("doTabChange"); 
            }
            if (IsCallback)
            {
                //UpdateMessage();
                //Login();
            }
            //doPoskBack();
        }

        //private void ShowAttendance()
        //{
        //    CBizHrmAttendanceLog objHrmAttendanceLog = new CBizHrmAttendanceLog();
        //    DataSet dsS = objHrmAttendanceLog.SelectForUserAttendance("", this.Operator, "", Epm.AppLogic.Framework.CDbAccess.GetSqlServerDateTime().ToString(),true);



        //    if (dsS.Tables[0].Rows.Count > 0)
        //    {
        //        string strAttdt = DateTime.Parse(dsS.Tables[0].Rows[0]["PLAN_ATTENDANCE_DT"].ToString()).ToString("yyyy-MM-dd") + " ";
        //        string strOnduty = "";
        //        string strOffduty = "";
        //        string strPOnduty = "";
        //        string strPOffduty = "";
        //        if (dsS.Tables[0].Rows[0]["ON_DUTY_TIME"].ToString() != string.Empty)
        //            strOnduty = DateTime.Parse(strAttdt + dsS.Tables[0].Rows[0]["ON_DUTY_TIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
        //        if (dsS.Tables[0].Rows[0]["OFF_DUTY_TIME"].ToString() != string.Empty)
        //            strOffduty = DateTime.Parse(strAttdt + dsS.Tables[0].Rows[0]["OFF_DUTY_TIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
        //        if (dsS.Tables[0].Rows[0]["PLAN_ON_DUTY_TIME"].ToString() != string.Empty)
        //            strPOnduty = DateTime.Parse(strAttdt + dsS.Tables[0].Rows[0]["PLAN_ON_DUTY_TIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
        //        if (dsS.Tables[0].Rows[0]["PLAN_OFF_DUTY_TIME"].ToString() != string.Empty)
        //            strPOffduty = DateTime.Parse(strAttdt + dsS.Tables[0].Rows[0]["PLAN_OFF_DUTY_TIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
        //        this.SetContrlValue("txtOnduty", strOnduty);
        //        this.SetContrlValue("txtOffduty", strOffduty);
        //        this.SetContrlValue("txtPOnduty", strPOnduty);
        //        this.SetContrlValue("txtPOffduty", strPOffduty);
        //        if (dsS.Tables[0].Rows[0]["SIGN_IN_TIME"].ToString() == string.Empty)
        //        { 
        //            this.ExecJScript("ShowWorkInfo();");
        //        }
        //        return;
        //    } 
        //}

        //private void doPoskBack()
        //{
        //    if (!IsPostBack)
        //        return;

        //    try
        //    {
        //        if (!string.IsNullOrEmpty(this.Request.Params["__EVENTTARGET"]) && this.Request.Params["__EVENTTARGET"] == "lbMessage")
        //        {
        //            if (userinfo.UserId == null || userinfo.UserId == string.Empty)
        //            {
        //                FormsAuthentication.RedirectToLoginPage();
        //            }
        //            else
        //                UpText();
        //        }
        //    }
        //    catch (Exception err)
        //    {
        //        //if (this.Request.Params["RadAJAXControlID"] == "RadAjaxManager1")
        //            //RadAjaxManager1.Alert(err.Message);
        //    }
        //}

        private void ShowLogo()
        {
            //CBizBseOffice objBseOffice = new CBizBseOffice();
            //DataSet dsOffice = objBseOffice.SelectByOfficeCde(this.OperatorOffice);
            //string strImgUrl;
            //if (dsOffice.Tables[0].Rows.Count == 1)
            //{
            //    if (dsOffice.Tables[0].Rows[0]["OFFICE_LOGO"].ToString().Trim() != "")
            //    {
            //        strImgUrl = msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + dsOffice.Tables[0].Rows[0]["OFFICE_LOGO"].ToString().Trim();
            //        string strScript = "ShowLogo('" + strImgUrl + "');";
            //        this.ExecJScript(strScript);
            //        //this.ClientScript.RegisterStartupScript(GetType(), this.ID + "ClientScript", strScript, true);
            //    }
            //}
            //DataTable dt = new DataTable();
            //dt.Columns.Add("dddd");
            //DataRow dr = dt.NewRow();
            //dr["dddd"] = msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "Images/Logo/Logo1.jpg";
            //dt.Rows.Add(dr);
            //DataRow dr2 = dt.NewRow();
            //dr2["dddd"] = msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "Images/Logo/Logo2.jpg";
            //dt.Rows.Add(dr2);

            ////this.RadRotatorLogo.DataSource = dt;
            ////this.RadRotatorLogo.DataBind();
        }

        //private void UpText()
        //{
        //    //this.txtStf.Text = string.Format("当前用户：{0}", userinfo.UserName);
        //    if (userinfo.UserId == null || userinfo.UserId == string.Empty)
        //    {
        //        this.tretajax.Value = "USER_NULL";
        //        //FormsAuthentication.RedirectToLoginPage();
        //    }
        //    else
        //    {
        //        this.tretajax.Value = "";
        //        //this.lbdl.Text = " <a href=\"javascript:LoginOut();\" id=\"pswEdit\">注销</a> ";
        //        //this.txtStf.Text = GetMsgShowString();
        //    }
        //}

        private void GetSysNoHtml()
        {
            //CBizSysPublicNotice objSysPn = new CBizSysPublicNotice();
            //SetContrlValue("divSysFolPnot", objSysPn.GetClientNotice(2, "viewClientNotic"));
            //SetContrlValue("divSysFolPHelp", objSysPn.GetClientHelp(2, "viewClientNotic"));
        }

        private string GetMsgShowString()
        {
            try
            {
                //CBizEpmFlowActionItem objEpmFlowActionItem = new CBizEpmFlowActionItem();
                //DataSet ds = objEpmFlowActionItem.SelectCurrAction("", userinfo.UserId);

                //CBizBseSms objBseSms = new CBizBseSms();
                ////string strUrlTem = "<a href=\"javascript:window.parent.pcSend.Show();\" id=\"AMESSAGEID\">发送</a> ";
                //string strUrlMB = "<font color='blue'><a href=\"javascript:var oWindow = window.SetView('{0}','{1}');\" id=\"{2}\">{3}</a></font>  ";
                ////strUrlTem += string.Format(strUrlMB, "Sys/wfSmsReader.aspx?TYPE=MSG", "查看信息", "MSGIDT", "信息{" + objBseSms.GetNewMessgeCount(userinfo.UserId).ToString() + "}");
                //string strUrlTem = string.Format(strUrlMB, msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "Pages/admin/Flow/wfSmsReader.aspx?TYPE=APPROVAL", "审批签收", "MSGIDT", "审批【" + objBseSms.GetNewApprovalCount(userinfo.UserId).ToString() + "】条");
                //strUrlTem += string.Format(strUrlMB, msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + "Pages/admin/Flow/wfSmsReader.aspx?TYPE=TASK", "查看任务", "MSGIDT", "流程【" + ds.Tables[0].Rows.Count.ToString() + "】条");
                return "";// strUrlTem;
            }
            catch (Exception err)
            {
                return err.Message;
            }
        }

        //private void doShowMsg()
        //{
        //    CBizEpmSysMessage objm = new CBizEpmSysMessage();
        //    DataSet DS = objm.SelectNotifyCountForShow(this.Operator);
        //    if (DS.Tables[0].Rows.Count > 0)
        //    {
        //        this.ExecJScript("Showmsga('" + DS.Tables[0].Rows[0]["E_MESSAGE"].ToString() + "','" + DS.Tables[0].Rows[0]["E_ACT"].ToString() + "');");
        //    }
        //}


        private void DoDateTimeShow()
        {
            string strDate = "今天是:" + DateTime.Now.Year.ToString() + "年" + DateTime.Now.Month.ToString() + "月" + DateTime.Now.Day.ToString() + "日";
            switch (DateTime.Now.DayOfWeek.ToString())
            {
                case "Sunday":
                    strDate = strDate + " 星期日";
                    break;
                case "Monday":
                    strDate = strDate + " 星期一";
                    break;
                case "Tuesday":
                    strDate = strDate + " 星期二";
                    break;
                case "Wednesday":
                    strDate = strDate + " 星期三";
                    break;
                case "Thursday":
                    strDate = strDate + " 星期四";
                    break;
                case "Friday":
                    strDate = strDate + " 星期五";
                    break;
                case "Saturday":
                    strDate = strDate + " 星期六";
                    break;
                default:

                    break;
            }
            this.SetContrlValue("spnDateShow", strDate);
        }


        //public string GetBusineFlowHtml() //业务导航
        public void GetBusineFlowHtml() //业务导航
        {

            //string strRetHtml = "";
            //CBizFwsfClientBk objFwsfClientItem222 = new CBizFwsfClientBk();
            //DataSet dsCSpmt = objFwsfClientItem222.SelectClientBkSpmtNavigtForHandler(this.OperatorOffice);

            //strRetHtml = "<div><ul id=\"FlowBox\">";

            //if (dsCSpmt.Tables[0].Rows.Count > 0)
            //{
            //    SetContrlValue("spnyepjnum", dsCSpmt.Tables[0].Rows[0]["EVALUATE_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["EVALUATE_SPMT_NUM"].ToString());

            //    SetContrlValue("spnqrzddnum", dsCSpmt.Tables[0].Rows[0]["BILL_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["BILL_SPMT_NUM"].ToString());

            //    SetContrlValue("spnqrtdnum", dsCSpmt.Tables[0].Rows[0]["BL_CONFIRM_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["BL_CONFIRM_SPMT_NUM"].ToString());

            //    SetContrlValue("spnhzzynum", dsCSpmt.Tables[0].Rows[0]["SHIPPMENT_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["SHIPPMENT_SPMT_NUM"].ToString());

            //    SetContrlValue("spnslddnum", dsCSpmt.Tables[0].Rows[0]["ACP_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["ACP_SPMT_NUM"].ToString());

            //    SetContrlValue("spnxzddnum", dsCSpmt.Tables[0].Rows[0]["NEW_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["NEW_SPMT_NUM"].ToString());
            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('','');return false;\"><div><img src=\"img/FOL_LOG_MSG.png\" /><br/>评价业务(" + ( + ")</div></li>";
            //    //strRetHtml += "<li class=\"FlowBox_arrow\"><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('','');return false;\"><div><img src=\"img/FOL_LOG_FREIGHT.png\" /><br/>确认账单(" + (dsCSpmt.Tables[0].Rows[0]["BILL_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["BILL_SPMT_NUM"].ToString()) + ")</div></li>";
            //    //strRetHtml += "<li class=\"FlowBox_arrow\"><img src=\"img/0054.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('提单确认','fol/wfFolBlConfirmFinder.aspx');return false;\"><div><img src=\"img/FOL_LOG_CONFIRM.png\" /><br/>确认提单(" + (dsCSpmt.Tables[0].Rows[0]["BL_CONFIRM_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["BL_CONFIRM_SPMT_NUM"].ToString()) + ")</div></li>";
            //    //strRetHtml += "<li class=\"FlowBox_arrow\"><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('作业中','fol/wfFolShipmentFinder.aspx?Status=Working');return false;\"><div ><img src=\"img/FOL_LOG_LOAD.png\" /><br/>货载作业(" + (dsCSpmt.Tables[0].Rows[0]["SHIPPMENT_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["SHIPPMENT_SPMT_NUM"].ToString()) + ")</div></li>";
            //    //strRetHtml += "<li class=\"FlowBox_arrow\"><img src=\"img/0054.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('外贸订舱','fol/wfFolEobClientBkFinder.aspx');return false;\"><div ><img src=\"img/FOL_LOG_ACCEPT.png\" /><br/>受理订单(" + (dsCSpmt.Tables[0].Rows[0]["ACP_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["ACP_SPMT_NUM"].ToString()) + ")</div></li>";
            //    //strRetHtml += "<li class=\"FlowBox_arrow\"><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('内贸订舱','fol/wfFolDobClientBkEditor.aspx?MODE=ADD');return false;\"><div><img src=\"img/FOL_LOG_NEW.png\" /><br/>新增订单(" + (dsCSpmt.Tables[0].Rows[0]["NEW_SPMT_NUM"].ToString() == "" ? "0" : dsCSpmt.Tables[0].Rows[0]["NEW_SPMT_NUM"].ToString()) + ")</div></li>";
            //}
            //else
            //{
            //    SetContrlValue("spnyepjnum", "0");

            //    SetContrlValue("spnqrzddnum", "0");

            //    SetContrlValue("spnqrtdnum", "0");

            //    SetContrlValue("spnhzzynum", "0");

            //    SetContrlValue("spnslddnum", "0");

            //    SetContrlValue("spnxzddnum", "0");

            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('','');return false;\"><div><img src=\"img/FOL_LOG_MSG.png\" /><br/>评价业务(0)</div></li>";
            //    //strRetHtml += "<li><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('','');return false;\"><div><img src=\"img/FOL_LOG_FREIGHT.png\" /><br/>确认账单(0)</div></li>";
            //    //strRetHtml += "<li><img src=\"img/0054.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('提单确认','fol/wfFolBlConfirmFinder.aspx');return false;\"><div><img src=\"img/FOL_LOG_CONFIRM.png\" /><br/>确认提单(0)</div></li>";
            //    //strRetHtml += "<li><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('作业中','fol/wfFolShipmentFinder.aspx?Status=Working');return false;\"><div><img src=\"img/FOL_LOG_LOAD.png\" /><br/>货载作业(0)</div></li>";
            //    //strRetHtml += "<li><img src=\"img/0054.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:AddTab('外贸订舱','fol/wfFolEobClientBkFinder.aspx');return false;\"><div><img src=\"img/FOL_LOG_ACCEPT.png\" /><br/>受理订单(0)</div></li>";
            //    //strRetHtml += "<li><img src=\"img/0053.png\" /></li>";
            //    //strRetHtml += "<li onclick=\"javascript:OpenSpmtForm('内贸订舱','fol/wfFolDobClientBkEditor.aspx?MODE=ADD');return false;\"><div><img src=\"img/FOL_LOG_NEW.png\" /><br/>新增订单(0)</div></li>";

            //}
            ////

            ////strRetHtml += "</ul></div>";
            ////return strRetHtml;
        }

        public override void InitialByParam()
        {
            try
            {
                if (strAction == "SHOW_ALL")
                {

                    //ShowAttendance();
                }
                else if (strAction == "SHOW_TIME")
                {
                    this.ExecJScript("ShowSystemTime('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');");
                }
                else if (strAction == "SHOW_MSG")
                {
                    GetBusineFlowHtml();
                    //doShowMsg();
                }

            }
            catch (Exception err)
            {
                //this.Alert("服务器端错误：" + err.Message);
            }
            base.InitialByParam();
        }
    }
}